home *** CD-ROM | disk | FTP | other *** search
- // UAppleEvents © 1996 Nick Beadman
- // Utility class for helping handle the AppleEvent Manager
-
- #pragma once
-
- class UAppleEvents
- {
- // object specification helpers
- public:
- // get the container of an object specifier
- static OSErr GetContainer(const AEDesc& inObjectSpecifier, AEDesc& outContainer);
-
- // sending apple events
- public:
- // waiting for a reply (will return an OSErr if the reply contains one)
- static OSErr SendWaitReply(const AppleEvent& inEvent, AppleEvent& outReply, Int32 inTimeout = kAEDefaultTimeout, AESendMode inAdditionalAttr = 0);
- // just do it
- static OSErr SendNoReply(const AppleEvent& inEvent, AESendMode inAdditionalAttr = 0);
-
- // check a reply for an error string or OSErr (returns whether there is one in the reply)
- public:
- static Boolean ExtractOSErr(const AppleEvent& inReply, OSErr& outErr);
- static Boolean ExtractErrorString(const AppleEvent& inReply, StringPtr outString);
-
- // handling interaction with user, call this function before poping up a modal dialog
- public:
- static OSErr InteractWithUser(NMRecPtr inNotificationRequest = nil, Int32 inTimeout = kAEDefaultTimeout);
-
- // must be called at application startup for recording to work
- public:
- static OSErr InitRecordability(void);
-
- // recording an apple event (send to self without executing)
- public:
- static OSErr Record(const AppleEvent& inEvent);
-
- // make a self addressed address desc (only here because UAppleEventsMgr's is private)
- public:
- static OSErr MakeSelfAddressDesc(AEAddressDesc& outSelfAddressDesc);
-
- // comparison routines
- public:
- static Boolean EqualTargetIDs(const TargetID& inTargetIDOne, const TargetID& inTargetIDTwo);
- static Boolean EqualObjectSpecifiers(const AEDesc& inObjectSpecOne, const AEDesc& inObjectSpecTwo);
-
- // setting the idle func (set if you provide a more specific idle function, nil means no idle func)
- public:
- static void SetIdleFunc(AEIdleProcPtr inIdleFunc);
-
- // the default idle event function for use with AESend or AEInteractWithUser
- // (%%%% does not handle mouse moved events, attachments or sleep time [set to 12 ticks])
- public:
- static pascal Boolean DefaultAEIdleFunc(EventRecord* inEvent, long* ioSleepTime, RgnHandle* ioMouseRegion);
-
- // the null one, that does nothing. use for events during drag and drop, etc.
- public:
- static pascal Boolean NullAEIdleFunc(EventRecord* inEvent, long* ioSleepTime, RgnHandle* ioMouseRegion);
-
- // the apple event handler that is called in response to recording starting or stopping
- private:
- static pascal OSErr RecordingHandler(const AppleEvent* inAppleEvent, AppleEvent* outAEReply, Int32 inRefCon);
-
- // storage
- private:
- static AEIdleProcPtr sIdleFunc;
- static Boolean sRecording;
- };
-